package pakete2;


import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

import java.awt.Rectangle;
import java.rmi.RMISecurityManager;

import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.Point;

public class SistemanSarrera extends JFrame {
	
	private EI_SegurtasunArduraduna segurArduraduna = new EI_SegurtasunArduraduna();
	
	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JLabel jLabel = null;

	private JLabel jLabel1 = null;

	private JTextField jTextField = null;

	private JTextField jPasswordField = null;

	private JButton jButton = null;

	private JLabel jLabel2 = null;

	/**
	 * This is the default constructor
	 */
	public SistemanSarrera() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(300, 250);
		this.setLocation(new Point(400, 250));
		this.setContentPane(getJContentPane());
		this.setTitle("Identifikatu");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(28, 140, 228, 30));
			jLabel2.setText("");
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(10, 70, 140, 25));
			jLabel1.setText("Pasahitza Sartu:");
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(10, 30, 140, 25));
			jLabel.setText("Erabiltzaile Izena sartu:");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(jLabel, null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(getJTextField(), null);
			jContentPane.add(getJPasswordField(), null);
			jContentPane.add(getJButton(), null);
			jContentPane.add(jLabel2, null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setBounds(new Rectangle(170, 30, 100, 25));
			
		}
		return jTextField;
	}

	/**
	 * This method initializes jPasswordField	
	 * 	
	 * @return javax.swing.JPasswordField	
	 */
	private JTextField getJPasswordField() {
		if (jPasswordField == null) {
			jPasswordField = new JPasswordField();
			jPasswordField.setBounds(new Rectangle(170, 70, 100, 25));
		}
		return jPasswordField;
	}
	
	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setBounds(new Rectangle(80, 105, 140, 30));
			jButton.setText("Sisteman Sartu");
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e){
					String s1 = jTextField.getText();
					String s2 = jPasswordField.getText();
					if (s1.equals("admin") && s2.equals("eraikikon")){
						segurArduraduna.setVisible(true);
						setVisible(false);
					}
					else JOptionPane.showMessageDialog(null, "ezin zara sartu, berriro saiatu");
				}
			});
			return jButton;
		}
		return null;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				SistemanSarrera thisClass = new SistemanSarrera();
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				System.setProperty("java.security.policy", "segurtasun.politika");
				if (System.getSecurityManager() == null) {
					System.setSecurityManager(new RMISecurityManager());
				}
				thisClass.setVisible(true);
			}
		});
	}
	
	

}